// pages/dachuLive/dachuLive.js
const API = require("../../http/API")
const http = require("../../http/http")

Page({

  /**
   * 页面的初始数据
   */
  data: {
    videoSrc: "http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400",
    
    page1: 1, // 大触讲座的页数
    page2:1, // 大触专访的页数
    page3:1, // 大触周边的页数
    live: [],
    // 往期直播课程
    course: [],
    showIndex: 0,
    // 大触专访
    daChu: [],
    // 大触周边
    zhouBian:[],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    
    this.getDaniu({ link: 'paging', live: 3, page: this.data.page1, heat: "N", is_live: 1 })
    this.getDaChu({link:'paging',type:'interview',page:this.data.page2})
    this.getZhouBian({link:'paging',page:this.data.page3})
  },
  getDaniu(obj) {
    http(API.daniu, obj).then(res => {
      this.setData({
        live: res.data.live,
        course: this.data.course.concat(res.data.course.data)
      })
    })
  },
  getDaChu(obj) {
    http(API.dachuzf,obj).then(res => {
      this.setData({
        daChu: this.data.daChu.concat(res.data.data)
      })
    })
  },
  getZhouBian(obj){
    http(API.dachuzb,obj).then(res=>{
      console.log(res.data.data);
      this.setData({
        zhouBian:this.data.zhouBian.concat(res.data.data)
      })
    })
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
   
    if (this.data.showIndex == 0) {
      this.setData({
        page1: this.data.page1 + 1
      })
      this.getDaniu({ link: 'paging', live: 3, page: this.data.page1, heat: "N", is_live: 1 })
    } else if (this.data.showIndex == 1) {
      this.setData({
        page2: this.data.page2 + 1
      })
      this.getDaChu({link:'paging',type:'interview',page:this.data.page2})
    }
    else if (this.data.showIndex == 2) {
      this.setData({
        page3: this.data.page3 + 1
      })
      this.getZhouBian({link:'paging',page:this.data.page3})
    }
  },
  changeIndex(e) {
    this.setData({
      showIndex: e.currentTarget.dataset.index,
    })
  },

  // onShow(){
  //   this.setData({
  //     page1: 1,
  //     page2: 1,
  //     page2: 1,
  //     live: [],
  //     course: [],
  //     daChu: [],
  //     zhouBian:[],
  //     showIndex: 0,
  //   })
  // }


})